Deep Learning with PyTorch 1.x. by Laura Mitchell

Deep Learning with PyTorch 1.x. by Laura Mitchell

Author:Laura Mitchell [Laura Mitchell]
Language: eng
Format: epub
Tags: COM016000 - COMPUTERS / Computer Vision and Pattern Recognition, COM004000 - COMPUTERS / Intelligence (AI) and Semantics, COM037000 - COMPUTERS / Machine Theory
Publisher: Packt
Published: 2019-11-29T08:22:57+00:00


Once the network is created, we can train the model using the same code as seen in the previous examples. The following is the code for training the model:

model = IMDBRnn(n_vocab,n_hidden,3,bs=32)

model = model.cuda()

optimizer = optim.Adam(model.parameters(),lr=1e-3)

def fit(epoch,model,data_loader,phase='training',volatile=False):

if phase == 'training':

model.train()

if phase == 'validation':

model.eval()

volatile=True

running_loss = 0.0

running_correct = 0

for batch_idx , batch in enumerate(data_loader):

text , target = batch.text , batch.label

if is_cuda:

text,target = text.cuda(),target.cuda()



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.